<template>
  <el-col v-loading="loading.state">
    <el-col>
      <el-table :data="deptdata">
        <el-table-column prop="cupoCaseNumNew" label="案件编号" align="center" min-width="120"></el-table-column>
        <el-table-column prop="deptNameOld" label="机构" align="center" min-width="120"></el-table-column>
        <el-table-column prop="cupoUserOld" label="催收员" align="center" min-width="120"></el-table-column>
      </el-table>
    </el-col>
    <el-col class="text-center btns">
      <el-button @click="orgConfirm">确认</el-button>
      <el-button @click="originalDistribution">原分配</el-button>
      <el-button @click="cancle">重选案件</el-button>
    </el-col>
  </el-col>
</template>
<script>
  import net from '@/util/net'
  import servers from '@/config/servers'

  export default {
    name: 'organization-confirm',
    data() {
      return {
        loading: {
          state: false
        },
        // 服务接口列表
        server: {
          getDepartCases: servers.CaseManage.get_depart_cases, // 获取机构持有案件数
          distributeCeaseInfo: servers.CaseManage.distribute_cease_info // 案件分配
        },
        // 机构
        deptdata: [],
        multipleSelection: []
      }
    },
    props: [
      'caseDataId',
      'caseDataNum'
    ],
    methods: {
      refresh(orgData) {
        this.deptdata = orgData.filter(v => v.disCaseType !== 0)
        console.log(this.deptdata, 456)
      },
      /**
       * 确认
       */
      orgConfirm() {
        let depIdList = []
        depIdList.push(this.$store.state.caseManage.case_allot_org.deptId)
        net.send({
          server: this.server.distributeCeaseInfo,
          data: {
            caseIdList: this.caseDataId,
            caseNumList: this.caseDataNum,
            depIdList: depIdList,
            disType: 0,
            isPan: 0,
            accReceivePoolModels: this.deptdata
          },
          loading: this.loading
        }).then((data) => {
          this.$emit('close')
          this.$emit('refresh')
          this.$message({
            type: 'info',
            message: '分配成功！'
          })
        }, err => {
          this.$message({
            type: 'info',
            message: err.reason
          })
        })
      },
      /**
       * 原分配
       */
      originalDistribution() {
        if (this.$store.state.caseManage.case_allot_org.deptId) {
          let depIdList = []
          depIdList.push(this.$store.state.caseManage.case_allot_org.deptId)
          net.send({
            server: this.server.distributeCeaseInfo,
            data: {
              caseIdList: this.caseDataId,
              caseNumList: this.caseDataNum,
              depIdList: depIdList,
              disType: 0,
              isPan: 1
            },
            loading: this.loading
          }).then((data) => {
            this.$emit('close')
            this.$emit('refresh')
            this.$message({
              type: 'info',
              message: '分配成功！'
            })
          }, err => {
            this.$message({
              type: 'info',
              message: err.reason
            })
          })
        }
      },
      cancle() {
        this.$emit('close')
      }
    }
  }

</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .btns {
    padding: 20px;
  }

</style>
